#include <vector>
#include <iostream>

using namespace std;

const int MAX = 0x3f3f3f3f;

int main()
{
    int N, T;
    cin >> N >> T;
    vector<int> val(N), cnt(N);
    int max_val = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> val[i];
        max_val = max(val[i], max_val);
    }
    for (int i = 0; i < N; i++)
        cin >> cnt[i];

    max_val *= max_val;
    int V = max_val + T;
    vector<int> dp(V + 1, MAX); // multipack
    dp[0] = 0;
    for (int i = 0; i < N; i++)
    {
        int M = cnt[i];
        int k = 1;
        while (k < M)
        {
            for (int v = V; v >= k * val[i]; v--)
                dp[v] = min(dp[v], dp[v - k * val[i]] + k);
            M -= k;
            k *= 2;
        }
        for (int v = V; v >= M * val[i]; v--)
            dp[v] = min(dp[v], dp[v - M * val[i]] + M);
    }

    vector<int> dp2(max_val + 1, MAX);//zeropack
    dp2[0] = 0;
    for (int i = 0; i < N; i++)
        for (int v = val[i]; v <= max_val; v++)
            dp2[v] = min(dp2[v], dp2[v - val[i]] + 1);

    int ans = MAX;
    for (int i = T; i <= V; i++)
        ans = min(dp[i] + dp2[i - T], ans);
    if(ans == MAX)
        cout << -1 << endl;
    else
        cout << ans << endl;

    return 0;
}